<?php
/**
 * SettingController.php
 *
 * @copyright   2023 thingsworld.com.cn - All Rights Reserved
 * @link        http://thingsworld.com.cn/
 * @author      stiffer.chen <chenl@thingsworld.com.cn>
 * @created     2023-08-22 15:51:05
 * @modified    2023-08-22 15:51:05
 *
 */

namespace App\Http\Controllers;

use App\Models\Setting;
use App\Repositories\SettingRepo;
use Illuminate\Http\Request;

class SettingController extends BaseController
{
    public function index(Request $request)
    {
        try {
            $data = SettingRepo::getAll();
            return message('获取成功', true, $data);
        } catch (\Exception $e) {
            return message($e->getMessage(), false);
        }
    }
    public function keys(Request $request)
    {
        try {
            $keys = SettingRepo::groupKeys();
            return message('获取成功', true, $keys);
        } catch (\Exception $e) {
            return message($e->getMessage(), false);
        }
    }

    // 更新配置项
    public function update(Request $request)
    {
        try {
            SettingRepo::modify();
            return message('更新成功');
        } catch (\Exception $e) {
            return message($e->getMessage(), false);
        }
    }
}